{include file="public_head" /}
<!-- upload -->
<link href="__STATIC__/css/uploads.css" rel="stylesheet">
<!-- upload_arr -->
<link href="__STATIC__/plupload/plupload.css" rel="stylesheet">
<!-- Select2 -->
<link href="__STATIC__/css/select/select2.min.css" rel="stylesheet">
<!-- sku -->
<link href="__STATIC__/css/sku.css" rel="stylesheet" type="text/css">
<link href="__STATIC__/multiselect/css/bootstrap-multiselect.css" rel="stylesheet" type="text/css">


<body class="nav-md">

<div class="container body">

    <div class="main_container">

        {include file="public_sidebar,public_nav" /}
        <!-- page content -->
        <div class="right_col" role="main">
            <div class="">

                <div class="page-title">
                    <div class="title_left">

                    </div>
                </div>
                <div class="clearfix"></div>
                <div class="row">
                    <div class="col-md-12 col-sm-12 col-xs-12">
                        <div class="x_panel">
                            <div class="x_title">
                                <h2>编辑门店
                                    <!--<small>different form elements</small>-->
                                </h2>
                                <ul class="nav navbar-right panel_toolbox">
                                    <li><a class="collapse-link"><i class="fa fa-chevron-up"></i></a>
                                    </li>
                                    <li><a class="close-link"><i class="fa fa-close"></i></a>
                                    </li>
                                </ul>
                                <div class="clearfix"></div>
                            </div>
                            <div class="x_content">
                                <br/>
                                <form class="form-horizontal form-label-left" enctype="multipart/form-data" action=""
                                      method="post" id="registerForm" onSubmit="return check()">



                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">门店二维码：</label>
                                        <div class="col-md-3 col-sm-6 col-xs-12">
                                            <img src="{$pic|default=''}" width="200"/>
                                        </div>
                                    </div>

                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">指定门店管理员：</label>
                                        <div class="col-md-3 col-sm-6 col-xs-12">
                                            <select name="shop_manage_id" class="select2_single"
                                                    style="width:100%;" tabindex="-1" {eq name=":session('auding_status')" value="1"}disabled{/eq}
                                            datatype="*"
                                            nullmsg="请选择所在城市！" errormsg="请选择所在城市！"
                                            >
                                            <option value="0">无</option>
                                            {volist name="shop_manage" id="sm"}
                                            <option value="{$sm.id}" {eq name='$item.shop_manage_id|default=""' value='$sm.id' }selected{/eq}>{$sm.nickname}</option>
                                            {/volist}
                                            </select>
                                        </div>
                                    </div>

                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">请选择店铺分类：</label>
                                        	
                                        <div class="col-md-6 col-sm-6 col-xs-12">
                                        	<style>
												.model_id{
                                                font: 14px/20px Arial;
													color: #777;
													background-color: #FFF;
													vertical-align: top;
													display: inline-block;
													padding: 4px;
													border: solid 1px #CCC;
													outline: 0 none;
													font-family: '微软雅黑';
												}
                                            </style>
                                            <?php $model_idd =  \think\Request::instance()->param('model_id'); ?>
                                        	<select style="width: 100px;" class="model_id" name="model_id" datatype="*"
                                                    nullmsg="请选择所属模型！" errormsg="请选择所属模型！" id="addr" onChange="sele_Change()">
                                               <option value=" " <?php if($model_idd==''){?> {eq name='$item.model_id|default=""' value=' ' }selected{/eq} <?php }?>>请选择所属模型</option>     
                                               <option value="1" <?php if($model_idd==''){?> {eq name='$item.model_id|default=""' value='1' }selected{/eq} <?php }elseif($model_idd!='' and $model_idd=='1'){?>selected <?php }?>>服务</option>
                                               <option value="2" <?php if($model_idd==''){?> {eq name='$item.model_id|default=""' value='2' }selected{/eq} <?php }elseif($model_idd!='' and $model_idd=='2'){?>selected <?php }?>>商品</option>
                                               <option value="3" <?php if($model_idd==''){?> {eq name='$item.model_id|default=""' value='3' }selected{/eq} <?php }elseif($model_idd!='' and $model_idd=='3'){?>selected <?php }?>>礼包</option>
                                            </select>
                                            
                                            
                                            
                                            <select id="example-enableClickableOptGroups" multiple="multiple" name="single_type[]" style="width: 300px;">
                                                {volist name="single_list" id="vo"}
                                                <optgroup label="
                                                <?php if($model_idd==''){?> {eq name='$item.model_id|default=""' value=' ' }{$vo.cat_name}{/eq} <?php }?>
                                                <?php if($model_idd==''){?> {eq name='$item.model_id|default=""' value='1' }{$vo.cat_name}{/eq} <?php }elseif($model_idd!='' and $model_idd=='1'){?>{$vo.cat_name} <?php }?>
                                                <?php if($model_idd==''){?> {eq name='$item.model_id|default=""' value='2' }{$vo.title}{/eq} <?php }elseif($model_idd!='' and $model_idd=='2'){?>{$vo.title} <?php }?>
                                                <?php if($model_idd==''){?> {eq name='$item.model_id|default=""' value='3' }{$vo.cat_name}{/eq} <?php }elseif($model_idd!='' and $model_idd=='3'){?>{$vo.cat_name} <?php }?>
                                                " class="group-{$vo.id}">
                                                    {volist name="$vo['son']" id="vv"}
                                                    <option value="{$vv.id}" {in name="vv.id" value="$item.single_type|default=''"}selected{/in}>-----
                                                    <?php if($model_idd==''){?> {eq name='$item.model_id|default=""' value=' ' }{$vv.cat_name}{/eq} <?php }?>
                                                	<?php if($model_idd==''){?> {eq name='$item.model_id|default=""' value='1' }{$vv.cat_name}{/eq} <?php }elseif($model_idd!='' and $model_idd=='1'){?>{$vv.cat_name} <?php }?>
                                                	<?php if($model_idd==''){?> {eq name='$item.model_id|default=""' value='2' }{$vv.title}{/eq} <?php }elseif($model_idd!='' and $model_idd=='2'){?>{$vv.title} <?php }?>
                                                	<?php if($model_idd==''){?> {eq name='$item.model_id|default=""' value='3' }{$vv.cat_name}{/eq} <?php }elseif($model_idd!='' and $model_idd=='3'){?>{$vv.cat_name} <?php }?>
                                                    </option>
                                                    {/volist}
                                                </optgroup>
                                                {/volist}
                                            </select>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">所在城市：</label>
                                        <div class="col-md-3 col-sm-6 col-xs-12">
                                            <select name="city_id" class="select2_single"
                                                    style="width:100%;" tabindex="-1" {eq name=":session('auding_status')" value="1"}disabled{/eq}
                                                    datatype="*"
                                                    nullmsg="请选择所在城市！" errormsg="请选择所在城市！"
                                            >
                                                {foreach :model('area')->where('area_deep',2)->select() as $key=>$vo }
                                                <option value="{$vo.area_id}" {eq name='$item.city_id|default=""' value='$vo.area_id' }selected{/eq}>{$vo.area_name}</option>
                                                {/foreach}
                                                {/volist}
                                            </select>
                                        </div>
                                    </div>


                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">门店名称：</label>
                                        <div class="col-md-3 col-sm-6 col-xs-12">
                                            <input type="text" placeholder="请填写门店名称" {eq name=":session('auding_status')" value="1"}disabled{/eq}
                                                   class="form-control col-md-7 col-xs-12" name="shop_title"
                                                   value="{$item.shop_title|default=''}" datatype="*" nullmsg="请填写门店名称"
                                            >
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">前台销量：</label>
                                        <div class="col-md-3 col-sm-6 col-xs-12">
                                            <input type="text" placeholder="请填写门店名称" {eq name=":session('auding_status')" value="1"}disabled{/eq}
                                            class="form-control col-md-7 col-xs-12" name="goods_sale"
                                            value="{$item.goods_sale|default=''}" datatype="*" nullmsg="请填写门店名称"
                                            >
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">门店电话：</label>
                                        <div class="col-md-3 col-sm-6 col-xs-12">
                                            <input type="text" placeholder="请填写门店电话" {eq name=":session('auding_status')" value="1"}disabled{/eq}
                                                   class="form-control col-md-7 col-xs-12" name="shop_phone"
                                                   value="{$item.shop_phone|default=''}" datatype="*" nullmsg="请填写门店电话"
                                            >
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">店主姓名：</label>
                                        <div class="col-md-3 col-sm-6 col-xs-12">
                                            <input type="text" placeholder="请填写店主姓名" {eq name=":session('auding_status')" value="1"}disabled{/eq}
                                                   class="form-control col-md-7 col-xs-12" name="shop_name"
                                                   value="{$item.shop_name|default=''}" datatype="*" nullmsg="请填写店主姓名"
                                            >
                                        </div>
                                    </div>
                                    {eq name=":session('auding_status')" value="2"}
                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">地图：</label>
                                        <div class="col-md-6 col-sm-6 col-xs-12">
                                            <div id="mapContainer" class="col-md-12 col-sm-12 col-xs-12" style="height:450px;border: 1px solid gray;"></div>
                                        </div>
                                    </div>
                                    {/eq}
                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">门店地址：</label>
                                        <div class="col-md-3 col-sm-6 col-xs-12">
                                            <input type="text"
                                                   class="form-control col-md-7 col-xs-12" name="shop_address"
                                                   placeholder="请输入要添加的地址关键字后,点击后面的搜索按钮即可自动获取经纬度" id="search"
                                                   value="{$item.shop_address|default=''}" datatype="*" nullmsg="请填写门店地址"
                                            >
                                            {eq name=":session('auding_status')" value="2"} <input  type="button" value="查询" class="col-sm-2 btn btn-default" onClick="geocoder();"/>{/eq}
                                        </div>
                                    </div>

                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">门店经度：</label>
                                        <div class="col-md-3 col-sm-6 col-xs-12">
                                            <input type="text" placeholder="请填写门店经度" readonly
                                                   class="form-control col-md-7 col-xs-12" name="longitude" id="longitude"
                                                   value="{$item.longitude|default=''}" datatype="*" nullmsg="请填写门店经度"
                                            >
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">门店纬度：</label>
                                        <div class="col-md-3 col-sm-6 col-xs-12">
                                            <input type="text" placeholder="请填写门店纬度" readonly id="latitude"
                                                   class="form-control col-md-7 col-xs-12" name="latitude"
                                                   value="{$item.latitude|default=''}" datatype="*" nullmsg="请填写门店纬度"
                                            >
                                        </div>
                                    </div>



                                    <div class="abc" style="display: none;"><li></li><li><input type="text" data_type="stock"/></li></div>
                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">门店列表【210*143】:</label>
                                        <div class="col-md-6 col-sm-6 col-xs-12">
                                            {eq name=":session('auding_status')" value="2"}
                                            <div id="imgdiv">
                                                <img id="imgShow" src="__PUBLIC__/{$item.thumbnail|default=''}"
                                                     width="200" height="190" onerror="this.src='__STATIC__/images/default.png'"
                                                />
                                            </div>
                                            <div class="uploader white">
                                                <input type="text" class="filename" name="thumbnail"
                                                       value="{$item.thumbnail|default=''}" readonly/>
                                                <input type="button" name="file" class="button" value="上传..."/>
                                                <input type="file" id="up_img" name="thumbnail"
                                                       value='{$item.thumbnail|default=""}'  />
                                            </div>
                                            {else/}
                                            <img id="imgShow" src="__PUBLIC__/{$item.thumbnail|default=''}"
                                                 width="200" height="190" onerror="this.src='__STATIC__/images/default.png'"
                                            />
                                            {/eq}
                                        </div>
                                    </div>

                                    <div class="divider-dashed"></div>

                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">门店组图：【720*400】</label>
                                        <div class="col-md-6 col-sm-6 col-xs-12">
                                            {eq name=":session('auding_status')" value="2"}
                                            <div class="uploader white">
                                                <input type="button" id="logo_upload_btn" class="button" value="批量上传"/>
                                            </div>

                                            <div id="logo_upload_area" style='width:80%'>
                                                <div id='photos_area' class="photos_area clearfix">

                                                    {if condition="($Request.action eq 'update') && ($item.picArr neq 'N;')"}
                                                    {foreach :unserialize($item['picArr']) as $picValue}
                                                    <div class="item">
                                                        <input type="hidden" name="picArr[]" value="{$picValue}">
                                                        <img src="__PUBLIC__/{$picValue}" width="100px" height="100px">
                                                        <div class="operate">
                                                            <i class="toleft">左移</i>
                                                            <i class="toright">右移</i>
                                                            <i class="del">删除</i>
                                                        </div>
                                                    </div>
                                                    {/foreach}
                                                    {/if}

                                                </div>
                                                <div class="alert alert-success" role="alert"
                                                     style="margin:10px 0;"><strong><span
                                                        class="glyphicon glyphicon-flag"></span>点击批量上传按钮上传多张图片:</strong>&nbsp;&nbsp;单张图片大小不超过500KB,格式为jpg,png,gif,jpeg
                                                </div>

                                            </div>
                                            {else/}
                                            <div id='photos_area' class="photos_area clearfix">

                                                {if condition="($Request.action eq 'update') && ($item.picArr neq 'N;')"}
                                                {foreach :unserialize($item['picArr']) as $picValue}
                                                <div class="item">
                                                    <input type="hidden" name="picArr[]" value="{$picValue}">
                                                    <img src="__PUBLIC__/{$picValue}" width="100px" height="100px">

                                                </div>
                                                {/foreach}
                                                {/if}

                                            </div>
                                            {/eq}

                                        </div>
                                    </div>

                                    <div class="divider-dashed"></div>
                                    {eq name=":session('auding_status')" value="2"}
                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">门店介绍：</label>
                                        <div class="col-md-6 col-sm-6 col-xs-12">
                                            <textarea type="text/plain" style=" height: 300px; width: 100%" id="containers"
                                                      name="content" {eq name=":session('auding_status')" value="1"}readonly{/eq}
                                                      placeholder="请输入商品内容">
                                                {$item.content|default=''}
                                            </textarea>
                                        </div>
                                    </div>
                                    {/eq}
                                    <div class="form-group">
                                        <label class="control-label col-md-3 col-sm-3 col-xs-12">排序：</label>
                                        <div class="col-md-3 col-sm-6 col-xs-12">
                                            <input type="text" placeholder="请填写排序" {eq name=":session('auding_status')" value="1"}readonly{/eq}
                                                   class="form-control col-md-7 col-xs-12" name="sort"
                                                   value="{$item.sort|default='0'}" datatype="*" nullmsg="请填写排序"
                                            >
                                        </div>
                                    </div>

                                    <!--<div class="form-group">-->
                                        <!--<label class="control-label col-md-3 col-sm-3 col-xs-12">预约启用状态：</label>-->
                                        <!--<div class="col-md-6 col-sm-6 col-xs-12">-->
                                            <!--<label class="radio_box">-->
                                                <!--<input type="radio" name="state" id="state_1" class="cartradio"-->
                                                       <!--value="1"-->
                                                       <!--datatype="*"-->
                                                       <!--nullmsg="请选择启用状态！" errormsg="请选择启用状态！"-->
                                                       <!--{eq name='item.state|default=""' value='1' }-->
                                                       <!--checked-->
                                                       <!--{/eq}-->
                                                <!--&gt;&nbsp;&nbsp;-->
                                                <!--<label for="state_1"></label>-->
                                                <!--<span>启用</span>-->
                                                <!--&nbsp;&nbsp;-->
                                            <!--</label>-->
                                            <!--<label class="radio_box">-->
                                                <!--<input type="radio" name="state" id="state_2" class="cartradio"-->
                                                       <!--value="2"-->
                                                       <!--datatype="*"-->
                                                       <!--nullmsg="请选择启用状态！" errormsg="请选择启用状态！"-->
                                                       <!--{eq name='item.state|default=""' value='2' }-->
                                                       <!--checked-->
                                                       <!--{/eq}-->
                                                <!--&gt;&nbsp;&nbsp;-->
                                                <!--<label for="state_2"></label>-->
                                                <!--<span>关闭</span>-->
                                                <!--&nbsp;&nbsp;-->
                                            <!--</label>-->
                                        <!--</div>-->
                                    <!--</div>-->

                                    {include file="auding_status" /}

                                    <div class="ln_solid"></div>

                                    <div class="form-group">
                                        <div class="col-md-6 col-sm-6 col-xs-12 col-md-offset-3">
                                            {present name="$item.id"}
                                            <input type="hidden" name="id" value="{$item.id}">

                                            {/present}
                                            <input type="hidden" name="member_id" value="{:session('shop_id')}"/>
                                            <button type="submit" class="btn btn-primary">提交</button>
                                            <a type="reset" class="btn btn-success" onClick="history.go(-1)">返回</a>
                                        </div>
                                    </div>

                                </form>
                            </div>
                        </div>
                    </div>
                </div>


            </div>
            <!-- /page content -->

        </div>

    </div>
</div>

{include file="public_foot" /}
<!-- upload_arr -->
<script src="__STATIC__/js/upload.photos.js"></script>
<script type="text/javascript" src="__STATIC__/plupload/plupload.full.min.js"></script>
<!-- Times -->
<script src='__STATIC__/js/datepicker/WdatePicker.js'></script>
<!-- validform -->
<script src="__STATIC__/js/Validform_v5.3.2_min.js"></script>
<script src="__STATIC__/js/layer.js"></script>
<!-- select -->
<script src="__STATIC__/js/select/select2.full.min.js"></script>
<script src="__STATIC__/multiselect/js/bootstrap-multiselect.js"></script>
<!-- upload -->
<script type="text/javascript" src="__STATIC__/js/uploadPreview.js"></script>

<!-- ueditor -->
<script type="text/javascript" charset="utf-8" src="__STATIC__/editor/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="__STATIC__/editor/ueditor.all.min.js"></script>
<script type="text/javascript" charset="utf-8" src="__STATIC__/editor/lang/zh-cn/zh-cn.js"></script>
<!--高德地图-->
<script src="http://cache.amap.com/lbs/static/es5.min.js"></script>
<script src="http://webapi.amap.com/maps?v=1.3&key=36ebe758894c100b6e3b81bddf4301d5"></script>
<script type="text/javascript" src="http://cache.amap.com/lbs/static/addToolbar.js"></script>
<script type="text/javascript" src="https://webapi.amap.com/demos/js/liteToolbar.js"></script>

<script type="text/javascript">
		var myURL = window.location.pathname;
		//执行选中select方法
       function sele_Change(){
        //var objS = document.getElementById("addr");
        var model_id = $('#addr option:selected') .val();
		//alert(model_id);
		if(myURL=='/index.php/console/shop/create.html'){
			window.location.href="/index.php/console/shop/create.html?model_id="+model_id;
		}
		else{
			window.location.href="/index.php/console/shop/update/model_id/"+model_id+"/id/{$item.id|default=''}.html";
		}
        //需要执行的事件（加载地图html）
       }
</script>



<script>
    var map = new AMap.Map('mapContainer', {
        resizeEnable: true,
        zoom:12,
    });
    map.plugin(["AMap.Scale"], function () {
        var scale = new AMap.Scale();
        map.addControl(scale);
    });
    map.plugin(["AMap.ToolBar"], function () {
        var ToolBar = new AMap.ToolBar();
        map.addControl(ToolBar);
    });
    map.plugin(["AMap.OverView"], function () {
        var OverView = new AMap.OverView();
        map.addControl(OverView);
    });

    addMarker();

    function addMarker() {
        //添加点标记
        var LngLatX = document.getElementById("longitude").value; // 获取Lng值
//        alert(LngLatX);
        var LngLatY = document.getElementById("latitude").value; // 获取Lat值
        clearMap();
        marker = new AMap.Marker({
            //icon: "http://webapi.amap.com/images/marker_sprite.png",
            map:map,
            position: [LngLatX, LngLatY]
        });

        marker.setMap(map); // 在地图上添加点
        map.setFitView(12); // 调整到合理视野
    }

    map.on('click', function (e) {
        document.getElementById("longitude").value=e.lnglat.getLng();
        document.getElementById("latitude").value=e.lnglat.getLat();
        addMarker();
    });

    function clearMap(){
        map.clearMap();
    }

    // select2
    $(".select2_multiple").select2({
        maximumSelectionLength: 0,
        placeholder: "请选择店铺分类",
        allowClear: true
    });

    function geocoder() {
        var keyword = document.getElementById("search").value;
//        alert(keyword);
        var MGeocoder;
        //加载地理编码插件
        AMap.service(["AMap.Geocoder"], function() {
            MGeocoder = new AMap.Geocoder({
                // city: "010", //城市，默认："全国"
                radius: 1000 //范围，默认：500
            });
            //返回地理编码结果
            //地理编码
            //alert(keyword);
            MGeocoder.getLocation(keyword, function(status, result) {
                if (status === 'complete' && result.info === 'OK') {
                    geocoder_CallBack(result);
                }
            });
        });
    }
    //地理编码返回结果展示
    function geocoder_CallBack(data) {
        var resultStr = "";
        //地理编码结果数组
        var geocode = new Array();
        geocode = data.geocodes;
        for (var i = 0; i < geocode.length; i++) {
            //拼接输出html
            resultStr += "<span style=\"font-size: 12px;padding:0px 0 4px 2px; border-bottom:1px solid #C1FFC1;\">" + "<b>地址</b>：" + geocode[i].formattedAddress + "" + "<b>&nbsp;&nbsp;&nbsp;&nbsp;坐标</b>：" + geocode[i].location.getLng() + ", " + geocode[i].location.getLat() + "" + "<b>&nbsp;&nbsp;&nbsp;&nbsp;匹配级别</b>：" + geocode[i].level + "</span>";
            //addmarker(i, geocode[i]);
            document.getElementById("longitude").value=geocode[i].location.getLng(); // Lng值
            document.getElementById("latitude").value=geocode[i].location.getLat(); // Lat值
            addMarker();
        }
        map.setFitView();
        //document.getElementById("result").innerHTML = resultStr;
    }
    $(function () {
        $(".wizard_steps li:nth-of-type(2)").click(
//            function () {
//                $("#step-2").show();
//            }
        )
    })
</script>
<script type="text/javascript">
    $(function () {
        $('#example-enableClickableOptGroups').multiselect({
            enableClickableOptGroups: true,
            enableCollapsibleOptGroups: true,
            selectAllNumber: false,
            nonSelectedText: '请选择店铺分类',
            buttonWidth: '300px',
        });
    });



</script>
<script>


    // validform
    $(function () {

        // select2
        $(".select2_single").select2({
            placeholder: "请选择分类",
            allowClear: true
        });
        $.Tipmsg.r = null;

        var showmsg = function (msg) {
            //假定你的店铺商品提示方法为showmsg， 在方法里可以接收参数msg，当然也可以接收到o及cssctl;
            alert(msg);
        }
        $("#registerForm").Validform({
            tiptype: function (msg) {
                layer.msg(msg);
            },
            tipSweep: true
        });

        // 实例化编辑器
        var ue = UE.getEditor('containers');
        var ue = UE.getEditor('containerss');

        // upload
        new uploadPreview({UpBtn: "up_img", DivShow: "imgdiv", ImgShow: "imgShow"});


        // 组图排序 删除图片
        $(".toleft").live("click", function () {
            var item = $(this).parent().parent(".item");
            var item_left = item.prev(".item");
            if ($("#photos_area").children(".item").length >= 2) {
                if (item_left.length == 0) {
                    item.insertAfter($("#photos_area").children(".item:last"));
                } else {
                    item.insertBefore(item_left);
                }
            }

        })

        $(".toright").live("click", function () {
            var item = $(this).parent().parent(".item");
            var item_right = item.next(".item");
            if ($("#photos_area").children(".item").length >= 2) {
                if (item_right.length == 0) {
                    item.insertBefore($("#photos_area").children(".item:first"));
                } else {
                    item.insertAfter(item_right);
                }
            }
        })

        $(".del").live("click", function () {
            $(this).parent().parent(".item").remove();
        })

        $(":radio").click(function () {

            if (this.checked) {
                if ($(this).attr("id") == "freight_type_1") {
                    $("#immobilization").show();
                    $("#template").hide();
                }else{
                    $("#immobilization").hide();
                    $("#template").hide();
                }
            }
        });
    });

    // 组图上传
    var uploader = new plupload.Uploader({
        runtimes: 'html5,flash,silverlight,html4',
        browse_button: 'logo_upload_btn',
        url: "/index.php/client/shop_goods/uploadarr.html",
        flash_swf_url: '__STATIC__/plupload/Moxie.swf',
        silverlight_xap_url: '__STATIC__/plupload/Moxie.xap',
        filters: {
            max_file_size: '500kb',
            mime_types: [
                {title: "files", extensions: "jpg,png,gif,jpeg"}
            ]
        },
        multi_selection: true,
        init: {
            FilesAdded: function (up, files) {
                $("#btn_submit").attr("disabled", "disabled").addClass("disabled").val("正在上传...");
                var item = '';
                plupload.each(files, function (file) { //遍历文件
                    item += "<div class='item' id='" + file['id'] + "'><div class='progress'><span class='bar'></span><span class='percent'>0%</span></div></div>";
                });
                $("#photos_area").append(item);
                uploader.start();
            },
            UploadProgress: function (up, file) { //上传中，显示进度条
                var percent = file.percent;
                $("#" + file.id).find('.bar').css({"width": percent + "%"});
                $("#" + file.id).find(".percent").text(percent + "%");
            },
            FileUploaded: function (up, file, info) {

                var data = eval("(" + info.response + ")");

                $("#" + file.id).html("<input type='hidden' name='picArr[]' value='" + data.src + "'><img src='__PUBLIC__/" + data.src + "' alt='" + data.name + "' width='100px' height='100px'><div class='operate'><i class='toleft'>左移</i><i class='toright'>右移</i><i class='del'>删除</i></div>")
                $("#btn_submit").removeAttr("disabled").removeClass("disabled").val("提 交");
                if (data.error != 0) {
                    layer.msg(data.error);
                }
            },
            Error: function (up, err) {
                layer.msg(err.message);
                $("#btn_submit").removeAttr("disabled").removeClass("disabled").val("提 交");
            }
        }
    });
    uploader.init();


        function delThisTr(trobj)
        {
            trobj.parent().parent().remove();
        }

        function delThis(trobj,id)
        {
            if(confirm('确认删除？')){
                $.ajax({
                    url : '{:url("ShopGoodsFlag/destroy")}',
                    data:{'id':id},
                    dataType:'html',
                    success:function(data){
                        if(data == 'true'){
                            layer.msg('删除成功');
                            trobj.parent().parent().remove();
                        }else{
                            layer.msg('网络繁忙,请重试');
                        }
                    }
                });
            }
        }
        $(".addNewTr").click(function(){
            str = '<tr><td><input type="text" name="nameAttr[]" style="width:100px;"/></td>' +
                '<td><input type="text" name="valueAttr[]" style="width:100px;" /></td>' +
                '<td><a href="javascript:;" onclick="delThisTr($(this))">删除</a></td></tr>';
            $("#fieldtr").append(str);
        });






</script>
<!-- daterangepicker -->
<script src="__STATIC__/js/datepicker/daterangepicker.js"></script>
<script type="text/javascript">
    $('#interval_timer').daterangepicker(null,
        function(start, end, label) {
            console.log(start.toISOString(), end.toISOString(), label);
        });
    var str = '<a href="http://www.baidu.com">链接111111111</a> ';
    var reg1 = /href=\"(.+)\"/g;
    var reg2 = /\">(.+)<\/a>/g;
    var retVal1 = reg1.exec(str);
    var retVal2 = reg2.exec(str);
    //alert(retVal1[1]);
    //alert(retVal2[1]);
</script>
<script src="__STATIC__/js/sku.js"></script>
</body>

</html>
